<template>
  <div>
    <div class="summary-row" v-if="healthChecks.length">
      <div class="summary-item">
        <span class="label">最近检测：</span>
        <span class="value">{{ healthChecks[0].type || '-' }}</span>
      </div>
      <div class="summary-item">
        <span class="label">结果：</span>
        <span class="value">{{ healthChecks[0].result || '-' }}</span>
      </div>
      <div class="summary-item">
        <span class="label">时间：</span>
        <span class="value">{{ healthChecks[0].date || '-' }}</span>
      </div>
    </div>
    <el-table :data="healthChecks.slice(0, 3)" style="width: 100%; margin-top: 10px;" v-if="healthChecks.length">
      <el-table-column prop="date" label="检测日期" />
      <el-table-column prop="type" label="检测类型" />
      <el-table-column prop="result" label="检测结果" />
    </el-table>
    <el-empty v-else description="暂无健康检测数据，快去首页添加吧！" />
  </div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { getHealthHistoryApi } from '../api/healthcheck'
const healthChecks = ref([])
onMounted(async () => {
  try {
    const res = await getHealthHistoryApi()
    healthChecks.value = res.data || []
  } catch {
    healthChecks.value = []
  }
})
</script>
<style scoped>
.summary-row {
  display: flex;
  gap: 24px;
  margin-bottom: 8px;
  font-size: 15px;
}
.summary-item .label {
  color: #888;
}
.summary-item .value {
  color: #409EFF;
  font-weight: bold;
}
</style> 